package com.woniuxy.microcurrentserver.exception;

import com.alibaba.fastjson.JSONObject;
import com.woniuxy.bean.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.io.IOException;

/**
 * Auther: wuson  <br/>
 * Date: 2021/3/17:11:28  <br/>
 * Description:
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public String handler(Exception e) throws IOException {
        log.error("发生异常",e);
        e.printStackTrace();
        return JSONObject.toJSONString(ResultBean.builder().code(1000).msg("服务异常，请联系管理员").build());
    }
}